home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / X11 / wais / waisgate / HTParse.h < prev    next >
C/C++ Source or Header  |  1995-05-09  |  4KB  |  152 lines

  1. /*                                                   HTParse:  URL parsing in the WWW Library
  2.                                          HTPARSE
  3.                                              
  4.    This module of the WWW library contains code to parse URLs and various related things.
  5.    Implemented by HTParse.c.
  6.    
  7.  */
  8. #ifndef HTPARSE_H
  9. #define HTPARSE_H
  10. #include "HTUtils.h"
  11.  
  12. /*
  13.  
  14.    The following are flag bits which may be ORed together to form a number to give the
  15.    'wanted' argument to HTParse.
  16.    
  17.  */
  18. #define PARSE_ACCESS            16
  19. #define PARSE_HOST               8
  20. #define PARSE_PATH               4
  21. #define PARSE_ANCHOR             2
  22. #define PARSE_PUNCTUATION        1
  23. #define PARSE_ALL               31
  24.  
  25.  
  26. /*
  27.  
  28. HTParse:  Parse a URL relative to another URL
  29.  
  30.    This returns those parts of a name which are given (and requested) substituting bits
  31.    from the related name where necessary.
  32.    
  33.   ON ENTRY
  34.   
  35.   aName                   A filename given
  36.                          
  37.   relatedName             A name relative to which aName is to be parsed
  38.                          
  39.   wanted                  A mask for the bits which are wanted.
  40.                          
  41.   ON EXIT,
  42.   
  43.   returns                 A pointer to a malloc'd string which MUST BE FREED
  44.                          
  45.  */
  46.  
  47. extern char * HTParse  PARAMS((const char * aName, const char * relatedName, int wanted));
  48.  
  49.  
  50. /*
  51.  
  52. HTStrip: Strip white space off a string
  53.  
  54.   ON EXIT
  55.   
  56.    Return value points to first non-white character, or to 0 if none.
  57.    
  58.    All trailing white space is OVERWRITTEN with zero.
  59.    
  60.  */
  61. #ifdef __STDC__
  62. extern char * HTStrip(char * s);
  63. #else
  64. extern char * HTStrip();
  65. #endif
  66.  
  67. /*
  68.  
  69. HTSimplify: Simplify a UTL
  70.  
  71.    A URL is allowed to contain the seqeunce xxx/../ which may be replaced by "" , and the
  72.    seqeunce "/./" which may be replaced by "/". Simplification helps us recognize
  73.    duplicate filenames. It doesn't deal with soft links, though. The new (shorter)
  74.    filename overwrites the old.
  75.    
  76.  */
  77. /*
  78. **      Thus,   /etc/junk/../fred       becomes /etc/fred
  79. **              /etc/junk/./fred        becomes /etc/junk/fred
  80. */
  81. #ifdef __STDC__
  82. extern void HTSimplify(char * filename);
  83. #else
  84. extern void HTSimplify();
  85. #endif
  86.  
  87.  
  88. /*
  89.  
  90. HTRelative:  Make Relative (Partial) URL
  91.  
  92.    This function creates and returns a string which gives an expression of one address as
  93.    related to another. Where there is no relation, an absolute address is retured.
  94.    
  95.   ON ENTRY,
  96.   
  97.    Both names must be absolute, fully qualified names of nodes (no anchor bits)
  98.    
  99.   ON EXIT,
  100.   
  101.    The return result points to a newly allocated name which, if parsed by HTParse relative
  102.    to relatedName, will yield aName. The caller is responsible for freeing the resulting
  103.    name later.
  104.    
  105.  */
  106. #ifdef __STDC__
  107. extern char * HTRelative(const char * aName, const char *relatedName);
  108. #else
  109. extern char * HTRelative();
  110. #endif
  111.  
  112.  
  113. /*
  114.  
  115. HTEscape:  Encode unacceptable characters in string
  116.  
  117.    This funtion takes a string containing any sequence of ASCII characters, and returns a
  118.    malloced string containing the same infromation but with all "unacceptable" characters
  119.    represented in the form %xy where X and Y are two hex digits.
  120.    
  121.  */
  122. extern char * HTEscape PARAMS((char * str, unsigned char mask));
  123.  
  124. /*
  125.  
  126.    The following are valid mask values.  The terms are the BNF names in the URL document.
  127.    
  128.  */
  129. #define URL_XALPHAS     (unsigned char) 1
  130. #define URL_XPALPHAS    (unsigned char) 2
  131. #define URL_PATH        (unsigned char) 4
  132.  
  133.  
  134. /*
  135.  
  136. HTUnEscape: Decode %xx escaped characters
  137.  
  138.    This function takes a pointer to a string in which character smay have been encoded in
  139.    %xy form, where xy is the acsii hex code for character 16x+y. The string is converted
  140.    in place, as it will never grow.
  141.    
  142.  */
  143. extern char * HTUnEscape PARAMS(( char * str));
  144.  
  145.  
  146. #endif  /* HTPARSE_H */
  147.  
  148.  
  149. /*
  150.  
  151.    end of HTParse  */
  152.